/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufpr.tads.ghtads.model;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author G0006185
 */
public class ConnectionFactory {
    
    public static Connection getConnection() throws FileNotFoundException, IOException, ClassNotFoundException, SQLException {
        String drive =  ConnectionFactory.getProp().getProperty("db.driver");
        String url =  ConnectionFactory.getProp().getProperty("db.url");
        String user =  ConnectionFactory.getProp().getProperty("db.user");
        String pwd =  ConnectionFactory.getProp().getProperty("db.pwd");
      Class.forName(drive);
      return DriverManager.getConnection(url, user, pwd);
  }
      private static Properties getProp() throws FileNotFoundException, IOException{
        
          
          
       Properties prop = new Properties();
       FileInputStream file = new FileInputStream("C:/Users/VictorHugo/Documents/NetBeansProjects/ghtads/src/java/br/ufpr/tads/ghtads/model/db.properties");
       prop.load(file);
       return prop;
   }
    
}
